package com.lkm.market2_0;

import com.lkm.javatool.NumberHelp;
import com.lkm.javatool.URLHelp;
import com.lkm.javatool.lang.NameValueP;
import com.lkm.market2_0.help.SteelardHelp;

//import org.apache.log4j.PropertyConfigurator;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;

import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;

public class MainTest {


    public static void main(String[] s) throws Exception {

//         Logger log = LoggerFactory.getLogger(Main.class);


        System.out.println(" d");
        System.out.println(" d".trim());
        System.out.println(" ".getBytes("GBK")[0]);
        try {
            System.out.println(URLHelp.parserUrlParamsToStr(new NameValueP[]{new NameValueP("ee", "dd cc")}));
            System.out.println(URLHelp.parserUrlParamsToStr(new NameValueP[]{new NameValueP("ee", "dd cc")}).replaceAll("\\+", "%20"));
        }catch (Exception e){};
    }
    public static void mains(String[] s){

        System.out.println(SteelardHelp.formatMoney(SteelardHelp.formatMoneyFloat(

                new BigDecimal(""+3.00).multiply(new BigDecimal(""+0.315)).floatValue()
                )));

        System.out.println(new BigDecimal(""+5.00f).multiply(new BigDecimal(""+1.987f)).floatValue());
        System.out.println((5.00d*1.987d));
        System.out.println((5.00f*1.987f));
        System.out.println("=="+floatScaleToString(floatScale((5.00f*1.987f),2,BigDecimal.ROUND_HALF_UP),2,BigDecimal.ROUND_HALF_UP));
    }
    public static String floatScaleToString(float value, int scale, int roundingMode) {
        BigDecimal bd = new BigDecimal(String.valueOf(value) );
        bd = bd.setScale(scale, roundingMode);
        float d = bd.floatValue();
        return String .format("%."+scale+"f",d);
    }
    public static float floatScale(float value, int scale, int roundingMode) {
        BigDecimal bd = new BigDecimal(String.valueOf(value) );
        bd = bd.setScale(scale, roundingMode);
        float d = bd.floatValue();
        return d;
    }
    
    public static String formatMoney(float value, int scale) {
        BigDecimal bd = new BigDecimal( String.valueOf(value) );
        bd = bd.setScale(scale, BigDecimal.ROUND_HALF_UP);
        float d = bd.floatValue();
        return d+"f";//String .format("%."+scale+"f",d);
    }
}
